package com.atguigu.myssm.myspringmvc;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * liujianlong
 * 2022-01-27 15:55
 * @author liujianlong
 */
@WebServlet("*.do")
public class Dispatcher extends ViewBaseServlet{
    protected void service(HttpServletRequest request, HttpServlet response)throws ServletException, IOException{
        //设置编码
        request.setCharacterEncoding("UTF-8");
        //假设URL是：http://localhost:8080/pro15/hello.do
        //那么servletPath是： /hello.do
        //思路：
        //第一步：/hello.do--> hello
        //第二步：hello-->HelloController

        String servletPath=request.getServletPath();
        servletPath=servletPath.substring(1);
        int lastDotIndex=servletPath.lastIndexOf(".do");
        servletPath=servletPath.substring(0,lastDotIndex);

    }
}
